package controller.listeners.posprocessingFrg;

import model.PosProcessingForeignsModel;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import business.ViewLogger;
import view.PosProcessingForeignsView;

public class IDNOSSelectionListener implements Listener {


	private PosProcessingForeignsView _view;
	private PosProcessingForeignsModel _model;
	
			public IDNOSSelectionListener(PosProcessingForeignsView view,
					PosProcessingForeignsModel model) {
				this._model = model;
				this._view = view;
			}
			
			@Override
			public void handleEvent(Event event) {
				 
				String idnoStr = _view.getSelectedIDNOTable();
				
				try {
					Integer idno = Integer.parseInt(idnoStr);
					_model.set_selected_idno(idno);
					_view.setRPs(_model.get_rps());
					_view.setCO0s(_model.get_co0s());
					
				} catch (NumberFormatException e) {
					ViewLogger.getInstance().error("El idno seleccionado no es un numero correcto");
				}
				
				
							
			}
		}